/*
 * This source code is part of TWaver 4.0
 *
 * Serva Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * Copyright 2002 - 2011 Serva Software. All rights reserved.
 */

package demo.chart.attachment.chartattachment;

import java.awt.Color;
import java.util.List;

import twaver.TWaverConst;
import twaver.chart.AbstractChart;
import twaver.chart.RadarChart;
import twaver.network.ui.ElementUI;

public class RadarElementAttachment extends ElementAttachment {

	public static final String RADARAXISLIST = "radarelementattachment.radaraxislist";

	public RadarElementAttachment(String name, ElementUI ui) {
		super(name, ui);
	}

	public RadarElementAttachment(String name, ElementUI ui, boolean minimized, boolean shrinked) {
		super(name, ui, minimized, shrinked);
	}

	private RadarChart chart;

	protected void initChart() {
		chart = new RadarChart();
		chart.setShapeFillGradient(false);
		chart.setAxisTextVisible(false);
		chart.setInflexionStyle(TWaverConst.INFLEXION_STYLE_TRIANGLE);
		chart.setAxisColor(Color.GRAY);
		chart.setScaleMajorTextVisible(false);
		setChartProperty(chart);
	}

	protected void setChartProperty(AbstractChart chart) {
		super.setChartProperty(chart);
		RadarChart rChart = (RadarChart) chart;
		Object obj = element.getClientProperty(RADARAXISLIST);
		if (obj != null) {
			List list = (List) obj;
			int size = list.size();
			for (int i = 0; i < size; i++) {
				rChart.addAxis(list.get(i));
			}
		}
	}

}